home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dfpp01.zip / APPLICAT.CPP next >
C/C++ Source or Header  |  1992-11-10  |  2KB  |  101 lines

  1. // ------------ applicat.cpp
  2.  
  3. #include "dflatpp.h"
  4.  
  5. void Application::OpenWindow(MenuBarItem *menu)
  6. {
  7.     extern DeskTop desktop;
  8.     desktop.SetApplication(this);
  9.     windowtype = ApplicationWindow;
  10.     if (windowstate == CLOSED)
  11.         DFWindow::OpenWindow();
  12.     SetAttribute(BORDER | SAVESELF | CONTROLBOX | STATUSBAR);
  13.     SetColors();
  14.     if (menu != NULL)       {
  15.         SetAttribute(MENUBAR);
  16.         menubar = new MenuBar(menu, this);
  17.     }
  18.     else
  19.         menubar = NULL;
  20.     statusbar = new StatusBar(this);
  21.     desktop.mouse().Show();
  22.     DFWindow::SetFocus();
  23.     takingfocus = False;
  24. }
  25.  
  26. void Application::CloseWindow()
  27. {
  28.     if (menubar != NULL)
  29.         delete menubar;
  30.     if (statusbar != NULL)
  31.         delete statusbar;
  32.     desktop.SetApplication(NULL);
  33.     DFWindow::CloseWindow();
  34. }
  35.  
  36. // -------- set the fg/bg colors for the window 
  37. void Application::SetColors()
  38. {
  39.     colors.fg = 
  40.     colors.sfg = 
  41.     colors.ffg = 
  42.     colors.hfg = LIGHTGRAY;
  43.     colors.bg = 
  44.     colors.sbg = 
  45.     colors.fbg = 
  46.     colors.hbg = BLUE;
  47. }
  48.  
  49. void Application::AdjustBorders()
  50. {
  51.     DFWindow::AdjustBorders();
  52.     if (attrib & MENUBAR)
  53.         TopBorderAdj++;
  54.     if (attrib & STATUSBAR)
  55.         BottomBorderAdj = 1;
  56. }
  57.  
  58. Bool Application::SetFocus()
  59. {
  60.     takingfocus = True;
  61.     DFWindow::SetFocus();
  62.     takingfocus = False;
  63.     return True;
  64. }
  65.  
  66. void Application::Show()
  67. {
  68.     if (!takingfocus || !isVisible())
  69.         DFWindow::Show();
  70.     else
  71.         Border();
  72. }
  73.  
  74. void Application::Keyboard(int key)
  75. {
  76.     switch (key)    {
  77.         case CTRL_F4:
  78.         case ALT_F4:
  79.             CloseWindow();
  80.             break;
  81.         default:
  82.             // ---- forward unprocessed keys to the menubar
  83.             if (menubar != NULL)
  84.                 menubar->Keyboard(key);
  85.             break;
  86.     }
  87. }
  88.  
  89. void Application::ClockTick()
  90. {
  91.     if (statusbar != NULL)
  92.         statusbar->ClockTick();
  93. }
  94.  
  95. void Application::StatusMessage(String& Msg)
  96. {
  97.     if (statusbar != NULL)
  98.         statusbar->StatusMessage(Msg);
  99. }
  100.  
  101.